/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.noah.validation;

import com.noah.model.UserModel;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

/**
 *
 * @author ngoc.phan
 */
public class LoginValidation implements Validator{

    @Override
    public boolean supports(Class<?> type) {
        //throw new UnsupportedOperationException("Not supported yet.");
        return UserModel.class.equals(type);
    }

    @Override
    public void validate(Object o, Errors errors) {
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "userName", "error.require");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "error.require");
    }
    
}
